package uk.ac.cam.echo.app;

import java.util.Calendar;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class NotificationActivity extends SecondaryActivity
{

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);

		String ns = Context.NOTIFICATION_SERVICE;
		NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

		// int icon = R.drawable.events_launcher;
		CharSequence tickerText = "Event X is about to start";
		Calendar c = Calendar.getInstance();
		c.setTimeInMillis(System.currentTimeMillis() + 5000);
		long when = c.getTimeInMillis();

		Notification.Builder nb = new Notification.Builder(this);

		CharSequence contentTitle = "May Ball";
		CharSequence contentText = "Event X is about to start";
		Intent notificationIntent = new Intent(this, EventsActivity.class);
		PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

		nb.setContentText(contentText);
		nb.setContentTitle(contentTitle);
		nb.setContentIntent(contentIntent);
		nb.setTicker(tickerText);
		// nb.setSmallIcon(R.drawable.events_launcher);
		nb.setWhen(when);

		Notification notification = nb.getNotification();

		final int HELLO_ID = 1;

		mNotificationManager.notify(HELLO_ID, notification);

		finish();
	}

}
